package com.banach.prema.executor;

import com.banach.prema.dto.cmd.ContactAdd;
import com.banach.prema.dto.cmd.ContactUpd;
import com.banach.prema.dto.vo.ContactVO;
import com.banach.prema.repository.ContactRepository;
import com.ego.framework.core.context.UserHolder;
import com.ego.framework.dto.Response;
import com.ego.framework.model.LoginUser;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ajun
 *
 */
@RestController
public class ContactSaveExe {

	@Resource
	private ContactRepository contactRepository;

	public Response create(ContactAdd contactAdd){
		LoginUser loginUser = UserHolder.getLoginUser();
		contactAdd.setUserId(loginUser.getId());
		return Response.build(contactRepository.create(contactAdd));
	}

	public Response update(ContactUpd contactUpd){
		LoginUser loginUser = UserHolder.getLoginUser();
		contactUpd.setUserId(loginUser.getId());
		return Response.build(contactRepository.update(contactUpd));
	}
}
